"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const index = require("../empty/index.cjs");
const _hoisted_1 = { class: "me-select-member-list" };
const _hoisted_2 = { class: "me-select-member-list-search" };
const _hoisted_3 = { class: "me-select-member-list-content" };
const _hoisted_4 = ["onClick"];
const _hoisted_5 = { class: "me-select-member-list-text" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "select-member-list",
  props: {
    memberList: { default() {
      return [];
    } },
    selectedMemberList: { default() {
      return [];
    } }
  },
  emits: ["click"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const keyword = vue.ref("");
    const memberList = vue.ref([]);
    const selectedMemberList = vue.ref([]);
    let cloneMemberList = JSON.parse(JSON.stringify(memberList.value));
    const emits = __emit;
    const hasMember = (member, list) => {
      let flag = false;
      list.map((item) => {
        if (item.value === member.value) {
          flag = true;
        }
      });
      return flag;
    };
    vue.onMounted(() => {
      memberList.value = props.memberList;
      cloneMemberList = JSON.parse(JSON.stringify(memberList.value));
      selectedMemberList.value = props.selectedMemberList;
      setSelectedMember();
    });
    vue.watch(() => props.memberList, () => {
      memberList.value = props.memberList;
      cloneMemberList = JSON.parse(JSON.stringify(memberList.value));
      setSelectedMember();
    });
    vue.watch(() => props.selectedMemberList, () => {
      selectedMemberList.value = props.selectedMemberList;
      setSelectedMember();
    });
    vue.watch(keyword, () => {
      memberList.value = JSON.parse(JSON.stringify(cloneMemberList));
      setSelectedMember();
      if (keyword.value) {
        memberList.value = memberList.value.filter((member) => member.title.includes(keyword.value));
      }
    });
    const setSelectedMember = () => {
      memberList.value.map((member) => {
        member.memberSelected = false;
        if (hasMember(member, selectedMemberList.value)) {
          member.memberSelected = true;
        }
      });
    };
    const onClick = (member) => {
      member.memberSelected = !member.memberSelected;
      emits("click", member);
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createElementVNode("div", _hoisted_2, [
          vue.createVNode(vue.unref(antDesignVue.Input), {
            value: keyword.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => keyword.value = $event),
            placeholder: "请输入"
          }, null, 8, ["value"])
        ]),
        vue.createElementVNode("div", _hoisted_3, [
          memberList.value.length > 0 ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(memberList.value, (member, index2) => {
            return vue.openBlock(), vue.createElementBlock("div", {
              onClick: ($event) => onClick(member),
              class: vue.normalizeClass(["me-select-member-list-item", { selected: member.memberSelected }]),
              key: index2
            }, [
              vue.renderSlot(_ctx.$slots, "member", { member }, () => [
                vue.createElementVNode("span", _hoisted_5, vue.toDisplayString(member.title), 1)
              ])
            ], 10, _hoisted_4);
          }), 128)) : (vue.openBlock(), vue.createBlock(vue.unref(index.Empty), {
            key: 1,
            description: "暂无数据"
          }))
        ])
      ]);
    };
  }
});
exports.default = _sfc_main;
//# sourceMappingURL=select-member-list.vue2.cjs.map
